package com.mhwx.mhlive;

import android.app.Activity;
import android.app.Application;

import com.mhwx.mhlive.ui.activity.MainActivity;
import com.umeng.socialize.Config;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;
import com.zhy.autolayout.config.AutoLayoutConifg;

import java.util.LinkedList;
import java.util.List;


public class   MyApplication extends Application {


    public static String mediaRef = "index";
    private static MyApplication sAppContext;
    private static MyApplication instance;
    private List<Activity> activityList = new LinkedList<Activity>();
    private static final String TAG = "MyApplication";
    private static final String RealmName="dalong.realm";
    public static long appOnlineStart = 0;
    public static boolean appOnline = false;
    // 单例模式中获取唯一的MyApplication实例
    public static MyApplication getInstance() {
        if (null == instance) {
            instance = new MyApplication();
        }
        return instance;
    }


    @Override
    public void onCreate() {
        super.onCreate();
        Config.DEBUG = true;
        sAppContext=this;
        UMShareAPI.get(this);
        //友盟第三方
        AutoLayoutConifg.getInstance().useDeviceSize();
        //视频
        com.cnlive.libs.util.Config.init(this, "399_j1nge50k61", "59b872b8c15a04f549dab2ea83fab28387cd841b54e3c4");

    }
    {
        PlatformConfig.setWeixin("wxdc0b3b1310482a73", "8f4fd0e2bacfd6e11f0b8c7b65033578");
        PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
        PlatformConfig.setSinaWeibo("3921700954", "04b48b094faeb16683c32669824ebdad", "http://sns.whalecloud.com");


    }
    public static MyApplication getAppContext() {
        return sAppContext;
    }



    // 遍历所有Activity并finish
    public void exitNoMain() {
        for (Activity activity : activityList) {
            if (activity instanceof MainActivity) {

            }else {
                activity.finish();
            }
        }
    }

    // 添加Activity到容器中
    public void addActivity(Activity activity) {
        activityList.add(activity);
    }

    // 添加Activity到容器中
    public void clearActivity() {
        activityList.clear();
    }
}
